package com.toune.movie.mvp.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.siberiadante.customdialoglib.BottomPopupWindow;
import com.toune.movie.R;
import com.toune.movie.base.Api;
import com.toune.movie.base.AppConstant;
import com.toune.movie.base.BaseActivity;
import com.toune.movie.base.myUtil.ProgressWebview;
import com.toune.movie.mvp.contract.VipVideoUrlContract;
import com.toune.movie.mvp.presenter.VipVideoUrlPresenter;
import com.vondear.rxui.view.RxRunTextView;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * Created by Administrator on 2018/5/9.
 */

public class VipVideoUrlActivity extends BaseActivity<VipVideoUrlPresenter> implements VipVideoUrlContract.View {
    @BindView(R.id.progress_wv)
    ProgressWebview progressWv;
    @BindView(R.id.copy_url_btn)
    Button copyUrlBtn;
    @BindView(R.id.tv_runtitle)
    RxRunTextView tvRuntitle;
    @BindView(R.id.select_url_btn)
    Button selectUrlBtn;

    @Override // 实例化presenter
    public VipVideoUrlPresenter initPresenter() {
        return new VipVideoUrlPresenter();
    }

    @Override
    public void loadMore() {

    }

    @Override
    public void refreData() {

    }

    @Override
    public void init(Bundle savedInstanceState) {
        progressWv.loadUrl(getIntent().getStringExtra("url"));
    }

    @Override
    protected int getLayout() {
        return R.layout.activity_vip_vido_url;
    }

    @Override
    protected String getTitleStr() {
        return getResources().getString(R.string.vip_movie);
    }

    @Override
    protected void initEventAndData() {

    }

    @Override
    public void showError(String msg) {

    }

    @Override
    public void useNightMode(boolean isNight) {

    }

    @Override
    public void onBackPressed() {
        progressWv.goBack();
    }

    @OnClick({R.id.select_url_btn, R.id.copy_url_btn})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.select_url_btn:
                final BottomPopupWindow bottomPopupWindow = new BottomPopupWindow(context).builder();
                for (int i = 0; i < AppConstant.JieXiUrl.length; i++) {
                    bottomPopupWindow.addSheetItem(AppConstant.JieXiUrlName[i], BottomPopupWindow.SheetItemColor.Blue, new BottomPopupWindow.OnSheetItemClickListener() {
                        @Override
                        public void onClick(int i) {
                            AppConstant.NowJieXiUrl = AppConstant.JieXiUrl[i];
                            selectUrlBtn.setText(AppConstant.JieXiUrlName[i]);
                        }
                    });
                }
                bottomPopupWindow.setCanceled(true);
                bottomPopupWindow.show();
                break;
            case R.id.copy_url_btn:
                Intent intent = new Intent(context, WebActivity.class);
                intent.putExtra("url", AppConstant.NowJieXiUrl + progressWv.getUrl());
                startActivity(intent);
                break;
        }
    }
}
